<!-- box menu -->
<?php $this->renderPartial("application.views.layouts._menu");?>
<!-- End box menu -->
<?php 
    $ryear = isset($year)?$year:date("Y");
    $rmonth = isset($month)?$month:date("m");
?>

<div class="about">
        <?php $this->widget("BoxLogin");?>
        <h1><a><img src="<?php echo Yii::app()->params['static_url'];?>images/tenweb-icon-doanh-thu.png" alt="" class="kc_TB_td" /></a><a href="#" class="xanhdam">Doanh Thu</a>
        </h1>
      <div class="DT">
            <form action="<?php echo  Url::createUrl('revenue/monthYear')?>" method="post">
            Tháng
             <select name="month" style="width:10%" class="mag-btt10">
                    <option value="1" class="w99" <?php echo $rmonth ==1?"selected='true'":"" ?>>1</option>
                    <option value="2" class="w99" <?php echo $rmonth ==2?"selected='true'":"" ?>>2</option>
                    <option value="3" class="w99" <?php echo $rmonth ==3?"selected='true'":"" ?>>3</option>
                    <option value="4" class="w99" <?php echo $rmonth ==4?"selected='true'":"" ?>>4</option>
                    <option value="5" class="w99" <?php echo $rmonth ==5?"selected='true'":"" ?>>5</option>
                    <option value="6" class="w99" <?php echo $rmonth ==6?"selected='true'":"" ?>>6</option>
                    <option value="7" class="w99" <?php echo $rmonth ==7?"selected='true'":"" ?>>7</option>
                    <option value="8" class="w99" <?php echo $rmonth ==8?"selected='true'":"" ?>>8</option>
                    <option value="9" class="w99" <?php echo $rmonth ==9?"selected='true'":"" ?>>9</option>
                    <option value="10" class="w99" <?php echo $rmonth ==10?"selected='true'":"" ?>>10</option>
                    <option value="11" class="w99" <?php echo $rmonth ==11?"selected='true'":"" ?>>11</option>
                    <option value="12" class="w99" <?php echo $rmonth ==12?"selected='true'":"" ?>>12</option>
             </select>
            &nbsp;Năm
             <select name="year" style="width:10%" class="mag-btt10">
             <?php
               $i=  date("Y"); 
               while($i>=2013)  
               {
?>
                 <option value="<?php echo $i ?>" class="w99"><?php echo $i ?></option>    
<?php                
               $i--;
               }
?>
             </select>
             
             <input type="submit" value="Thống kê" class="button_DT"/>
           <br />    </form>   
            <div class="DT_1">Lựa chọn nhanh: 
                <a href="<?php echo Url::createUrl("revenue/index")?>" class="chu_DT">Hôm nay</a>&nbsp;  
                <a href="<?php echo Url::createUrl("revenue/yesterday")?>" class="chu_DT">Hôm qua</a>&nbsp;       
                <a href="<?php echo Url::createUrl("revenue/month")?>" class="chu_DT">Tháng này</a>&nbsp; 
                <a href="<?php echo Url::createUrl("revenue/preMonth")?>" class="chu_DT">Tháng trước</a>&nbsp;
            </div>
            <div class="DT_2">
                <strong class="xanhdam">Chi Tiết Doanh Thu</strong><br />
                <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#dadcda">
                  <tr class="bg_DT_tr_1">
                    <td class="DT_a"><Strong>STT</Strong></td>
                    <td class="DT_b"><Strong>Nội dung</Strong></td>
                    <td class="DT_a"><Strong>Click</Strong></td>
                    <td class="DT_a"><Strong>User</Strong></td>
                    <td class="DT_a"><Strong>Sms</Strong></td>
                    <td class="DT_a"><Strong>Thẻ</Strong></td>
                    <td class="DT_b"><Strong>Doanh Thu</Strong></td>
                  </tr>
<?php
// Get Revenue Game Online
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_GAMEONLINE);
 ?>                  
                  <tr class="bg_DT_tr_2">
                    <td class="DT_a">1</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_GAMEONLINE)); ?>"> Game Online </a></td>
                    <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
<?php
// Get Revenue Game Offline
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_GAMEOFFLINE);
 ?>                   
                  <tr class="bg_DT_tr_2">
                    <td class="DT_a">2</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_GAMEOFFLINE)); ?>"> Game Offline </a></td>
                     <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
<?php
// Get Revenue Clip
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_CLIP);
 ?>                    
                   <tr class="bg_DT_tr_2">
                    <td class="DT_a">3</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_CLIP)); ?>"> Clip </a></td>
                    <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
<?php
// Get Revenue App
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_APP);
 ?>                    
                   <tr class="bg_DT_tr_2">
                    <td class="DT_a">4</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_APP)); ?>"> App </a></td>
                    <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
<?php
// Get Revenue Kich hoat apk
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_KICHHOATAPK);
 ?>                    
                   <tr class="bg_DT_tr_2">
                    <td class="DT_a">5</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_KICHHOATAPK)); ?>"> Kich hoạt APK </a></td>
                    <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
<?php
// Get Revenue Kich hoat java
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_KICHHOATJAVA);
 ?>                    
                   <tr class="bg_DT_tr_2">
                    <td class="DT_a">6</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_KICHHOATJAVA)); ?>"> Kich hoạt JAVA </a></td>
                    <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
<?php
// Get Revenue charging
  $rowGame = getArrayRevenueByType($rowsRevenue,ConstantsUtil::TYPE_CHARGING);
 ?>                    
                   <tr class="bg_DT_tr_2">
                    <td class="DT_a">7</td>
                    <td class="DT_b"><a href="<?php echo Url::createUrl("revenue/detail",array("userId"=>$_SESSION['userId'],"day"=>$day,"month"=>$month,"year"=>$year,"type"=>ConstantsUtil::TYPE_CHARGING)); ?>"> Charging </a></td>
                    <td class="DT_a"><?php echo empty($rowGame["click"])?0:$rowGame["click"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["userReg"])?0:$rowGame["userReg"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["sms"])?0:$rowGame["sms"]?></td>
                    <td class="DT_a"><?php echo empty($rowGame["card"])?0:$rowGame["card"]?></td>
                    <td class="DT_b"><?php echo empty($rowGame["revenue_member"])?0:$rowGame["revenue_member"]?></td>
                  </tr>
                </table>    
            </div>
      </div>    
      <!-- box footer -->
           <?php $this->widget("BoxFooter");?>
      <!-- end box footer -->
</div>

<?php

function getArrayRevenueByType($rowsRevenue,$type_value){
   $rowGame  = null;
   $i = 0;
   while($i<count($rowsRevenue))
   {
       foreach($rowsRevenue[$i] as $key=>$value){
           if(intval($value)==$type_value&&$key=="type")
           {
                $rowGame = $rowsRevenue[$i] ;
                break;
           }
       }
        $i++;
   } 
   return $rowGame;
}
    
?>